-
-
Notifications
You must be signed in to change notification settings - Fork 4k
feat(builders): refinements #11124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(builders): refinements #11124
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11124 +/- ##
==========================================
+ Coverage 44.46% 44.56% +0.10%
==========================================
Files 312 313 +1
Lines 17956 17995 +39
Branches 1790 1790
==========================================
+ Hits 7984 8020 +36
- Misses 9960 9963 +3
Partials 12 12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say it's a valuable addition.
Maybe add a test case of a simple & useful scenario? That could be nice to see! Reason I ask is because the documentation given for refining doesn't seem to solve a problem?
Will do. But the idea is that when you have a large block of logic that does a lot of conditional work on a builder, it can feel a bit "disconnected" and other logic can sneak in the middle, you also can end up introducing a lot of variables. With <TextBasedChannel>.send({
embeds: [new EmbedBuilder().refine(builder => { /* ... complex logic here */ });
}); |
I proposed this idea originally in that "random convo", (and I think I first saw the idea somewhere else). The main reason is I just otherwise find it pretty inconvenient when I'm working with a long chain of builder method calls. In my experience, it's sometimes annoying to conditionally modify the builder with external if statements and all that, rather than being able to put everything in one long expression. Especially when dealing with components nested inside other components/objects, and typescript gets mad at me without a bunch of type guards. I just much prefer being able to throw a code block in the middle of it rather than dealing with a bunch of variables, which feels more cluttered idk if I'm making sense. I made my own custom container builder and added this function and I like it, and I wish djs had it (and I'm annoyed javascript has no way to do this sort of thing natively). |
bb1b9e4
to
7a9c6ee
Compare
* .setDescription('This is a description') | ||
* .refine((b) => { | ||
* const intermediateValue = computeSomething(); | ||
* b.setFooter(`Computed value: ${intermediateValue}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an object!
Got the idea from a random convo I saw, I'd say it's a valuable addition. Method name inspired from zod, we can change if anyone has a better idea